package com.bjesc_b2c.app.appraiset.base;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Window;
import android.widget.Toast;

import com.rxretrofit_build.net.RxSubscriber;

import rx.Observable;
import rxbus_base.SuperRxBusBaseActivity;

/**
 * Created by Jason Chen on 2017/2/20.
 */

public class BaseActivity extends SuperRxBusBaseActivity {
    protected RxSubscriber rxSubscriber;
    protected Observable observable;
    protected Toast toast;
    protected ProgressDialog mProgressDia;
    protected Activity activity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
    }
    protected void showToast(String text){
        if(toast == null){
            toast = Toast.makeText(this,text,Toast.LENGTH_LONG);
        }else{
            toast.setText(text);
        }
        toast.show();
    }
    protected String getResourceString(int resourceId){
        return getResources().getString(resourceId);
    }
    protected void startIntent(Intent intent ,boolean isFinish){
        startActivity(intent);
        if(isFinish){
            finish();
        }
    }
    protected void startIntent(Intent intent,int requestId){
        startActivityForResult( intent, requestId);

    }
    @Override
    public Resources getResources() {
        Resources res = super.getResources();
        Configuration config=new Configuration();
        config.setToDefaults();
        res.updateConfiguration(config,res.getDisplayMetrics() );
        return res;
    }

//    //在这里加一个显示的dialog
//    protected void showProgressDialog() {
//        showProgressDialog("加载中...");
//    }
//
//    public void showProgressDialog(String msg)
//    {
//        if (mProgressDia == null)
//        {
//            mProgressDia = new ProgressDialog(this);
//            mProgressDia.setCancelable(false);
//            mProgressDia.setCanceledOnTouchOutside(false);
//        }
//        mProgressDia.setMessage(msg);
//        if (!mProgressDia.isShowing() && !activity.isFinishing())
//            mProgressDia.show();
//    }
//
//    public void dismissProgressDialog()
//    {
//        if (mProgressDia != null && mProgressDia.isShowing() && !activity.isFinishing())
//            mProgressDia.dismiss();
//    }


}
